package customer

import (
	"fmt"
	"yundata-service/internal"

	"github.com/dgrijalva/jwt-go"

	cm "yundata-service/pkg/model/customer"
)

type MemberAction struct {
	internal.ActionModel
}

func (ac *MemberAction) GetMemberList() {

	c := ac.Ctx
	user := c.MustGet("user").(jwt.MapClaims)
	fmt.Println(user)

	json := make(map[string]interface{})
	c.BindJSON(&json)

	var members []cm.Member
	// 获取数据
	db := internal.GDb

	db = db.Model(&cm.Member{})

	db.Limit(10)
	// 获取总数
	var total int64
	db.Count(&total)
	// 获取数据
	db.Find(&members)

	// 约定返回对象
	type Data struct {
		Members []cm.Member `json:"memberList"`
		Total   int64       `json:"total"`
	}

	// 返回数据

	resData := &Data{
		Members: members,
		Total:   total,
	}

	ac.Success("获取成功", resData)
}
